import request from "@/utils/request";
import { AxiosPromise } from "axios";
import {SysFeedbackForm, SysFeedbackQuery} from "@/api/feedback/types";

/**
* 用户反馈表数据
*
* @param queryParams
*/
export function getSysFeedbackPage(
queryParams: SysFeedbackQuery
): AxiosPromise<PageResult<[]>> {
return request({
url: '/api/v1/feedback/page',
method: 'get',
params: queryParams
});
}


/**
* 获取用户反馈表表单数据
*
* @param queryParams
*/
export function getSysFeedbackForm(id: number): AxiosPromise<SysFeedbackForm> {
    return request({
    url: '/api/v1/feedback/' + id + '/form',
    method: 'get'
    });
    }

    /**
    * 保存用户反馈表
    *
    * @param data
    */
    export function saveSysFeedback(data: SysFeedbackForm) {
    return request({
    url: "/api/v1/feedback",
    method: "post",
    data: data,
    });
    }

    /**
    * 删除用户反馈表
    *
    * @param ids
    */
    export function deleteSysFeedback(ids: string) {
        return request({
        url: '/api/v1/feedback/' + ids,
        method: 'delete'
        });
    }

    /**
    * 导入用户反馈表
    *
    * @param file
    */
    export function importSysFeedback(file: any) {
        const formData = new FormData();
        formData.append('file', file);
        return request({
            url: '/api/v1/feedback/sysFeedbackImport',
            method: 'post',
            data: formData,
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        });
    }

    /**
    * 导出用户反馈表
    *
    * @param ids
    * @returns
    */
    export function exportSysFeedback(ids: any) {
        return request({
            url: '/api/v1/feedback/_export?ids='+ids,
            method: 'get',
            responseType: 'arraybuffer'
        });
    }